<template>
  <page-form :x-uri="uri" :bind-rules="rules">
    <!-- 自定义tab -->
    <template v-slot:page-tabs>
      <tabs :tabs="tabs" />
    </template>
  </page-form>
</template>

<script>
import PageForm from '@public/template/page_form.vue';
import Tabs from '../tabs';
export default {
  components: {
    PageForm,
    Tabs
  },
  data() {
    return {
      uri: '/school/admin/level/create',
      tabs: [
        {
          title: '新建等级',
          uri: '/school/level/create',
          meta: {
            permission: 'school.level.create'
          }
        }
      ],
      rules: {
        proportion: [
          { required: true, message: '分成比例必须填写', trigger: ['blur', 'change'] },
          {
            validator: (rule, value, callback) => {
              const reg = /^\d+(\.\d{1,2})?$/;
              if (!reg.test(value)) {
                return callback(new Error('分成比例只能为正整数或2位以下小数'));
              }
              callback();
            },
            trigger: ['blur', 'change']
          }
        ]
      }
    };
  }
};
</script>
